<?php

namespace App\Validators;

trait PassesValidator{

    public function passes($action = null){
        $rules  = $this->getRules($action);
        if(method_exists($this,'callBackGetRules')){
            $rules=$rules=$this->callBackGetRules($rules);
        }
        $messages=isset($this->rulesMessages)?$this->rulesMessages:[];
        $validator = $this->validator->make($this->data, $rules,$messages);
        if( $validator->fails()) {
            $this->errors = $validator->messages();
            return false;
        }
        return true;
    }
}
